package com.resume.controller;

import java.util.List;

import com.resume.model.Resume;
import com.resume.tools.AjaxResult;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

public class ResumeController {

    /**
     * 用于打印日志
     */
    private static Logger logger = LoggerFactory.getLogger(ResumeController.class);

    @Autowired
    private IResumeService resumeService;

    /**
     * 添加
     *
     * @param resume 简历信息
     */
     @PostMapping("add")
     public AjaxResult add(@RequestBody Resume resume) {
        resumeService.add(resume);
        return new AjaxResult("Add Success");
     }

     /**
     * 查询列表
     */
    @GetMapping("list")
    @ResponseBody
    public AjaxResult list() {
        List<Resume> list = resumeService.list();
        return new AjaxResult(list);
    }

    /**
     * 更新简历
     *
     * @param resume 更新信息
     */
    @PostMapping("update")
    public AjaxResult update(@RequestBody Resume resume) {
        resumeService.update(resume);
        return new AjaxResult("Update Success");
    }

    /**
     * 删除简历
     *
     * @param map the map
     */
    @PostMapping("delete")
    public AjaxResult delete(@RequestBody Map map) {
        resumeService.delete((Integer) map.get("id"));
        return new AjaxResult("Delete Success");
    }

    /**
     * 下载pdf
     *
     * @param response
     * @param id
     */
     public void download()

}